<template>
  <div>
    <el-card>
      <div class="form">
        <el-form :model="adminInfo">
          <el-form-item label="用户名">
            <el-input
              v-model="adminInfo.username"
              placeholder="输入用户名"
            ></el-input>
          </el-form-item>
          <el-form-item label="旧密码">
            <el-input
              v-model="adminInfo.oldPassword"
              type="password"
              placeholder="输入旧密码"
            ></el-input>
          </el-form-item>
          <el-form-item label="新密码">
            <el-input
              v-model="adminInfo.newPassword"
              type="password"
              placeholder="输入新密码"
            ></el-input>
          </el-form-item>
          <el-form-item label="姓名">
            <el-input
              v-model="adminInfo.nickName"
              placeholder="输入您的真实姓名"
            ></el-input>
          </el-form-item>
          <el-form-item label="电话">
            <el-input
              v-model="adminInfo.phone"
              placeholder="输入您的电话"
            ></el-input>
          </el-form-item>
          <el-form-item label="邮箱">
            <el-input
              v-model="adminInfo.email"
              placeholder="输入您的邮箱"
            ></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="submitForm('ruleForm')"
              >修 改</el-button
            >
            <el-button @click="resetForm('ruleForm')">重 置</el-button>
          </el-form-item>
        </el-form>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  name: "AdminInfo",
  data() {
    return {
      adminInfo: {
        username: "",
        oldPassword: "",
        newPassword: "",
        nickName: "",
        phone: "",
        email: "",
      },
    };
  },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert("submit!");
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
  },
};
</script>

<style lang="less" scoped>
.el-card {
  margin-left: 10rem;
  margin-right: 10rem;
  .form {
    padding: 2rem;
    margin: 0 auto;
  }
}
</style>